import GameApp from './Game/GameApp';
import ResMgr from './Managers/ResMgr';
import UIMgr from './Managers/UIMgr';
import { dynamicCreateMask } from './Utils/UiCreate';

const { ccclass, property } = cc._decorator;

@ccclass
export class GameLaunch extends cc.Component {
    public static Instance: GameLaunch = null as unknown as GameLaunch;

    protected onLoad(): void {
        if (GameLaunch.Instance === null) {
            GameLaunch.Instance = this;
        } else {
            this.destroy();
            return;
        }

        // 初始化游戏框架：资源管理模块，网络模块，协议模块，日志模块……
        this.node.addComponent(ResMgr);

        this.node.addComponent(UIMgr);

        this.node.addComponent(GameApp);
    }

    start() {
        // 资源监测更新
        GameApp.Instance.EnterGame();

        console.log(cc.assetManager, '缓存管理');

        // 添加一个遮罩
        dynamicCreateMask();
    }

    // update (dt) {}
}
